home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Games: Greatest Hits 1996
/
Amiga Games: Greatest Hits 1996.iso
/
rexx
/
spelldocument.epxx
< prev
next >
Wrap
Text File
|
1996-07-27
|
6KB
|
215 lines
/************************************************************************/
/* */
/* File : SpellDocument.epxx */
/* Author : Martin Reddy */
/* Version : 1.2 */
/* Date : 12/1/95 */
/* Purpose : An ARexx script used to control the text editor EdWord */
/* Note : This is part of the Spell Checking facility of EdWord */
/* Function : This script file will check the spelling for the entire */
/* document (from the cursor position or top of file - see */
/* below for customisation) */
/* Updates : [27/7/96] - Cleaned up ProgInd, added more error checking */
/* */
/************************************************************************/
/* Set IGNORE_VALID_ROOTS to TRUE if you want the spell check to
ignore words which aren't in the dictionary, but do have a
valid root, e.g. ignore WASTED if the word WASTE exists in the
dictionary. This reduces the need to have every tense of a
word, and plurals, to be explicitly stored in the dictionary */
IGNORE_VALID_ROOTS = TRUE
/* Set CHECK_FROM_CURSOR to TRUE to make the spell check perform
from the current cursor position to the end of file. If you
set it to FALSE, then the spell check will be performed from
the very start of the file to then end, i.e. the entire file */
CHECK_FROM_CURSOR = TRUE
/*-------------- Nothing To Change Below Here -----------*/
HOST = ADDRESS()
ADDRESS VALUE HOST
OPTIONS RESULTS
/********** Make sure that the ISpell process is up *********/
IF ~SHOW( PORTS, 'IRexxSpell' ) THEN DO
Message "Loading Dictionary..."
ADDRESS COMMAND 'run <nil: >nil: EdSpell:ISpell/ispell -r >nil: <nil:'
ADDRESS COMMAND 'EdSpell:ISpell/WaitForPort IRexxSpell'
IF RC ~= 0 THEN DO
Inform "Could Not Start ISpell Process|Spell Check Aborted!"
Message ""
EXIT
END
END
/**************** Get a Word From The User *****************/
MODE = "From Cursor"
IF CHECK_FROM_CURSOR ~= TRUE THEN DO
MoveBOF
MoveBOL
MODE = "From Top of File"
END
GetChar
IF RESULT <= " " THEN MoveNextWord
Message "Spell Checking Document ("||MODE||")..."
SetView OFF
ProgressIndicator
GetEOLWrap; EOLSAVE=RESULT; SetEOLWrap ON
GetWord
DO FOREVER
IF RC ~= 0 THEN LEAVE
WORD = UPPER(RESULT)
SetIndicatorFile
CALL CheckWord(WORD)
GetNextWord
END
/**************** All done now: quit... ****************/
CALL CloseDown
Inform "End of Document Reached|Spell Check Completed."
EXIT
/************ PROCEDURE: "CloseDown" ************/
CloseDown: PROCEDURE EXPOSE EOLSAVE
Message ""
SetEOLWrap EOLSAVE
ProgressIndicator
SetView ON
RETURN
/************ PROCEDURE: "AbortSpellCheck" ************/
AbortSpellCheck: PROCEDURE
CHOICE "Do You Really Want To|Terminate This Spell Check?@@Yes, Stop|No, Continue"
IF RC == 1 THEN DO
BlockOff
CALL CloseDown
EXIT
END
MovePrevWord
RETURN
/************ PROCEDURE: "HighlightWord" ************/
HighlightWord: PROCEDURE
MoveRight
MovePrevWord
BlockStart
MoveNextWord
BlockEnd
MovePrevWord
ProgressIndicator
SetView ON
RETURN
/************ PROCEDURE: "AddWord(word)" ************/
AddWord: PROCEDURE
PARSE ARG THEWORD
Choice "Please Confirm The Addition of|"||THEWORD||" To The Dictionary.@@Add Word|Cancel"
IF RC ~= 0 THEN DO
ADDRESS "IRexxSpell" ADD THEWORD
END
RETURN
/************** PROCEDURE: TurnOffView ****************/
TurnOffView: PROCEDURE
BlockOff
Message "Spell Checking Document..."
SetView OFF
ProgressIndicator
RETURN
/************ PROCEDURE: "CheckWord(word)" ************/
CheckWord: PROCEDURE EXPOSE IGNORE_VALID_ROOTS
PARSE ARG SEARCHWORD
SEARCHWORD = COMPRESS( SEARCHWORD, '~`,./<>?;:"[]{}!@#$%^&*()+|=\- ' )
IF SEARCHWORD == '' THEN RETURN
INTERACT = FALSE
ADDRESS "IRexxSpell" CHECK SEARCHWORD
WORD = RESULT
IF WORD == "*" THEN DO
RETURN
END; ELSE IF LEFT(WORD,1) == "+" THEN DO
IF IGNORE_VALID_ROOTS == TRUE THEN RETURN
CALL HighlightWord
PARSE VAR WORD DUMMY ROOT
Choice SEARCHWORD" Is A Valid Combination|But Is Not In Dictionary|(Root Word Is:"||ROOT||")@@Ignore|Stop|Add Word"
IF RC == 0 THEN DO
CALL AddWord(SEARCHWORD)
END; ELSE IF RC == 2 THEN DO
CALL AbortSpellCheck
END
CALL TurnOffView
END; ELSE IF LEFT(WORD,1) == "&" THEN DO
CALL HighlightWord
PARSE VAR WORD DUMMY SUGA SUGB SUGC SUGD SUGE
SUG = "|1) "SUGA
IF (SUGB ~= "END") & (SUGB ~= "") & (SUGB ~= "SUGB") THEN DO
SUG = SUG||"|2) "||SUGB
END
IF (SUGC ~= "END") & (SUGC ~= "") & (SUGC ~= "SUGC") THEN DO
SUG = SUG||"|3) "||SUGC
END
IF (SUGD ~= "END") & (SUGD ~= "") & (SUGD ~= "SUGD") THEN DO
SUG = SUG||"|4) "||SUGD
END
INTERACT = TRUE
PROMPT = "'"||SEARCHWORD||"' Not In Dictionary|Possible Suggestions Are:|"||SUG
END; ELSE DO
CALL HighlightWord
INTERACT = TRUE
PROMPT = "'"||SEARCHWORD||"' Not In Dictionary|No Possible Suggestions Found"
END
IF INTERACT == TRUE THEN DO
Choice PROMPT||"@@Ignore|Add/Edit|Stop"
IF RC == 0 THEN DO
CALL AbortSpellCheck
END; ELSE IF RC == 2 THEN DO
Choice "Word = '"||SEARCHWORD||"'|| Edit = Edit Current Word | Add = Add Word To Dictionary|Cancel = Continue Spell Check @@Edit|Add|Cancel"
IF RC == 1 THEN DO
GetInput "Type New Spelling For Word (Blank=Abort)"
NEWWORD = RESULT
IF NEWWORD ~= "RESULT" & NEWWORD ~= "" THEN DO
DeleteWord
InsertText D2C(34)||NEWWORD||" "||D2C(34)
MovePrevWord
END
END; ELSE IF RC == 2 THEN DO
CALL AddWord(SEARCHWORD)
END
END
CALL TurnOffView
END
RETURN